<template>
  <div class="tip-container">
    <van-overlay :show="showTip" @click="overlayClick">
      <div class="box" @click.stop>
        <div class="top">
          <div class="title">{{title}}</div>
          <div class="close-wrapper">
            <div class="close" v-if="showClose" @click="close"></div>
          </div>
        </div>
        <slot />
      </div>
    </van-overlay>
  </div>
</template>
<script>
export default {
  props: {
    showClose: {
      type: Boolean,
      default: true
    },
    title: {
      type: String,
      default: '提示'
    },
    overlayHide: {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {
      showTip: false
    }
  },
  methods: {
    overlayClick () {
      if (this.overlayHide) {
        this.showTip = false
      }
    },
    show () {
      this.showTip = true
    },
    hide () {
      this.showTip = false
    },
    close () {
      this.showTip = false
    }
  }
}
</script>
<style lang="scss" scoped>
@import "@/styles/mixin.scss";
.tip-container {
  .box {
    width: 6.78rem;
    background: #fff;
    padding: 0.6rem 0.7rem;
    box-sizing: border-box;
    @include center();
    .top {
      width: 100%;
      position: relative;
      .title {
        font-size: 0.36rem;
        font-family: PingFang SC;
        font-weight: 500;
        color: rgba(0, 4, 0, 1);
        line-height: 0.42rem;
        text-align: center;
      }
      .close-wrapper {
        padding: 0.2rem;
        @include vCenter();
        right: 0;
      }
      .close {
        width: 0.28rem;
        height: 0.28rem;
        background: url("../../assets/images/icon_X.png") no-repeat;
        background-size: cover;
      }
    }
  }
}
</style>
